package framework;

import java.io.File;
import org.newdawn.slick.Color;
import org.newdawn.slick.GameContainer;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.Music;
import org.newdawn.slick.SlickException;

/**
 * A stage is the place where a fight is taking place.
 * @author blaze
 *
 */
public class Stage implements Entity, Drawable, Updatable, Scalable {
	
	protected Image bg;
	
	protected Music music;
	
	private int height;
	
	private int width;
	
	private float scale;
	
	public Stage() {
		// loading the background
		try {
			bg = new Image(C.ASSETS_STAGES_FOLDER + this.getClass().getSimpleName() + File.separator + "background.jpg");
		    music = new Music(C.ASSETS_STAGES_FOLDER + this.getClass().getSimpleName() + File.separator + "music.ogg");
		} catch (SlickException e) {
			System.out.println("One or many media missing, it'll feel either silent or empty");
			e.printStackTrace();
		}
	}
	
	public void init(GameContainer gc) {
		setWidth(gc.getWidth());
		setHeight(gc.getHeight());
		setScale(Util.getScale(gc));
	}
	
	public void playMusic() {
	   music.loop();
	}
	
	public void stopMusic() {
		music.stop();
	}

	@Override
	public void draw(Graphics g) {
		bg.draw(0, 0, getWidth(), getHeight());
	}
	
	public int getGroundHeight() {
		return 72;
	}
	
	public int getGroundHeight(GameContainer gc) {
		return (int) (getGroundHeight() * Util.getScale(gc));
	}

	@Override
	public void draw(Graphics g, Color filter) {
		draw(g);
	}

	@Override
	public void update(GameContainer gc, int Delta) {
		
	}

	@Override
	public int getX() {
		return 0;
	}

	@Override
	public int getY() {
		return 0;
	}

	@Override
	public int getWidth() {
		return this.width;
	}

	@Override
	public int getHeight() {
		return this.height;
	}

	@Override
	public void setX(int x) {
		
	}

	@Override
	public void setY(int y) {
		
	}

	@Override
	public void setWidth(int width) {
        this.width = width;
	}

	@Override
	public void setHeight(int height) {
		this.height = height;
	}

	@Override
	public void setScale(float scale) {
		this.scale = scale;
	}

	@Override
	public float getScale() {
		return this.scale;
	}
}
